/*
 * Tarea.java
 *
 * Created on 5 de mayo de 2007, 09:28 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package adsi.branchbound3;
import java.util.*;
/**
 *
 * @author Aramis
 */
public class Tarea {
    
    GregorianCalendar RJ = new GregorianCalendar();
    long numTarea; //numMantenimiento
    int pj;     //tiempodeMantenimiento
    public int rj; //deadline
    int dj;         //deadline + tiempodeMantenimiento
    boolean modificable;
    int disponibilidad=0;
    boolean programada=false;
    public Calendar HOY;
    private int Today;
    /** Creates a new instance of Tarea */
    public Tarea() {
        numTarea=0;
        pj=0;
        rj=0;
        dj=0;
    }
    public Tarea(long numTar,GregorianCalendar r, int duracion)
    {
        numTarea=numTar;
        HOY=Calendar.getInstance(TimeZone.getTimeZone("Mexico/General"));
        HOY.add(Calendar.SECOND, -1);
        Today=HOY.get(1)*365+(HOY.get(2)+1)*30+HOY.get(5);
        RJ=r;
        rj=RJ.get(1)*365+(RJ.get(2)+1)*30+RJ.get(5);
        pj=duracion;
        dj=rj+pj;
        
    }
    public long getNumTarea()
    {
        return numTarea;
    }
    public Calendar getRJ()
    {
        return RJ;
    }
    
    public int getToday()
    {
        return Today;
    }

    public void setProgramada(boolean prog)
    {
        programada=prog;
    }
    public int getDisponibilidad() {
        return disponibilidad;
    }
    public int getPj()
    {
        return pj;
    }
    public Tarea(int n,int p,int r,int d){
        numTarea=n;
        pj=p;
        rj=r;
        dj=d;
    }
    public Tarea(int n,int p,int r,int d, int dispo){
        numTarea=n;
        pj=p;
        rj=r;
        dj=d;
        disponibilidad=dispo;
    }
     public Tarea(int n,int p,int r,int d, int dispo, boolean modif){
        numTarea=n;
        pj=p;
        rj=r;
        dj=d;
        disponibilidad=dispo;
        modificable=modif;
    }
    public void decrementaRj()
    {
        RJ.add(Calendar.DAY_OF_MONTH,-1);
        rj=RJ.get(1)*365+(RJ.get(2)+1)*30+RJ.get(5);
        //rj--;
    }
    public int regresaRj()
    {
        return rj;
    }
    public void imprime()
    {
        System.out.println("Tarea " + numTarea + " Rj=" + rj + " Dj=" + dj + " Pj=" + pj);
    }
    public boolean equals(Tarea t)
    {
        if(t.numTarea==numTarea)
            return true;
        else
            return false;
    }

    public int getDj()
    {
        return dj;
    }
    public boolean modificable()
    {
        if (Today-rj<=30) //CONSIDERAR EL HOY...hoy-rj<30
            modificable=false;
        else
            modificable=true;
        return modificable;
    }
    
}
